package com.sakura.thread.chapter6;

import java.util.ArrayList;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Created by apple on 2018/12/18.
 */
public class ReentrantLockList {
    private ArrayList<String> array = new ArrayList<String>();
    private volatile ReentrantLock lock = new ReentrantLock();


    public void add(String e){
        lock.lock();
        try{
            array.add(e);
        }catch (Exception a) {

        }finally {
            lock.unlock();
        }

    }

    public void remove(String e){
        lock.lock();
        try{
            array.remove(e);
        }catch (Exception a) {

        }finally {
            lock.unlock();
        }
    }


}
